<include file="header" />
<div class="wraper">
    <div class="search-product">
        <a href="javascript:;" class="iconfont icon-zuozuo"></a>
        <p class="search-box"><span class="iconfont icon-search pull-left"></span><input class="pull-left" type="text" placeholder="请输入商品关键字" id="keyword" value="{BEESCRM:$keyword}"/></p>
        <a href="javascript:;" id="classify"><span class="iconfont icon-fenlei1"></span><p>分类</p></a>
    </div>
    <div class="classify-list">
         <a href="{BEESCRM::U('base/storeOld/goodsLists', array('order' => 'recommend', 'did' => $did, 'origin' => $origin, 'keyword' => $keyword, 'cate_id' => $cate_id))}" <if condition="$order eq 'recommend' "> class="current" </if>>新品</a>
        <a href="{BEESCRM::U('base/storeOld/goodsLists', array('order' => 'sale_num', 'did' => $did, 'origin' => $origin, 'keyword' => $keyword, 'cate_id' => $cate_id))}" <if condition="$order eq 'sale_num' "> class="current" </if>>销量</a>
        <a href="{BEESCRM::U('base/storeOld/goodsLists', array('order' => 'goods_price', 'did' => $did, 'origin' => $origin, 'keyword' => $keyword, 'order_by' => $order_by, 'cate_id'=>$cate_id))}" <if condition="$order eq 'goods_price' "> class="current" </if>>价格<p><span class="triangle-top" <if condition="$order_by eq 'asc' ">style="border-color:transparent transparent #3da359 transparent"<else/>style="border-color:transparent transparent #000 transparent"</if>></span><span class="triangle-bottom" <if condition="$order_by eq 'asc' ">style="border-color:#000 transparent transparent transparent"<else/>style="border-color:#3da359 transparent transparent transparent"</if>></span></p></a>
        <a href="javascript:;"><span class="iconfont icon-fenlei"></span></a>
    </div>
	<div class="half-contain clearfix product">
		<volist name="data" id="vo">
			<a href="{BEESCRM::U('base/storeOld/goodsdetail',array('store_id'=>$storeId,'goods_id'=>$vo['goods_id'],'did'=>$did,'origin'=>$origin))}" class="tabulation half clearfix">
				<div class="tabulation-img"><img src="{BEESCRM:$vo['goods_thumb']}"/></div>
				<div class="tabulation-info">
					<p class="tabulation-name">{BEESCRM:$vo['goods_name']}</p>
					<p class="prize"><span class="new-prize">￥{BEESCRM:$vo['goods_price']}</span><s class="old-prize">￥{BEESCRM:$vo['goods_original_price']}</s></p>
					<p><span class="discount">{BEESCRM:$vo['discount']}折</span><span class="sale">已售{BEESCRM:$vo['sale_num']}</span></p>
				</div>
			</a>
		</volist>
	</div>
</div>
<div class="pop-classify">
    <p class="list">选择分类<span class="pull-right" id="cancel">取消</span></p>
    <volist name="cate" id="vo">
    	<a href="{BEESCRM::U('base/storeOld/goodsList',array('cate_id'=>$vo['cate_id'],'did'=>$did,'origin'=>$origin))}" <if condition="$vo['cate_id'] eq $cate_id">class="list actived"<else/>class="list"</if>>{BEESCRM:$vo['cate_name']}<span class="iconfont icon-xuanzedianjihou pull-right"></span></a>
    </volist>
</div>
<a href="javascript:;" class="back-to-top"><span class="iconfont icon-fanhuidingbu"></span><p>顶部</p></a>
<include file="Store:commonJs" />
<include file="Store:footer" />
<script>
	var half_img_width = $('.half .tabulation-img').width();
	$('.half .tabulation-img img').css('height',half_img_width);
    $(function(){
        $('#classify').click(function(){
            $('.pop-classify').show();
        });
        $('#cancel').click(function(){
            $('.pop-classify').hide();
        });
        $('.pop-classify').on('click','p',function(){
            $(this).addClass('actived').siblings().removeClass('actived');
        })
    })
$(document).ready(function(){
	$('.icon-search').on('click',function(){
		var keyword=$('#keyword').val();
		if(keyword){
			window.location.href = "{BEESCRM::U('base/storeOld/goodsLists',array('wechat_id' => $wechat_id, 'did' => $did, 'origin' => $origin))}/keyword/"+keyword;
		}else{
			alert('搜索条件为空');
		}
	});

	$(document).ready(function(){
		var page = 2,
			url="{BEESCRM:$url}",
			flag = true;

		$(window).scroll(function(){
			if(($(window).scrollTop() + $(window).height() > $(document).height() - 40)){
				if(flag) {
					flag = false;
					$.ajax({
						type:"GET",
						url:url,
						data:{'page': page},
						dataType:'json',
						beforeSend:function(){
							$('.data-loding').show();//显示加载时候的提示
						},
						success:function(data){
							var str ='';
							if(data.status=='S'){
								if(data.data.length > 0) {
									$('.data-loding').hide();
									$.each(data.data,function(i,k){										
										str += "<a href='"+k.url+"' class='tabulation half clearfix'>"+
										"<div class='tabulation-img'><img src='"+ k.goods_thumb+"'/></div>"+
										"<div class='tabulation-info'>"+
										"<p class='tabulation-name'>"+ k.goods_name+"</p>"+
										"<p class='prize'><span class='new-prize'>"+k.goods_price+"</span><s class='old-prize'>"+k.goods_original_price+"</s></p>"+
										"<p><span class='discount'>"+k.discount+"折</span><span class='sale'>已售"+ k.sale_num+"</span></p></div></a>";								
									});
									$(".product").append(str);
									page++;
									flag = true;
								} else {
									$('.data-loding').hide();
									flag = false;
								}
							}
						}
					});
				}
			}
		})
	})
});
</script>
